package com.jubaozan.c3.framework.logs.logback;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.boolex.EventEvaluatorBase;
import lombok.RequiredArgsConstructor;

import lombok.extern.slf4j.Slf4j;

/**
 * @author jiangjinwu
 * @version 1.0
 * @since 2025/10/8 10:45
 */

@Slf4j

public class CustomLogEvaluator  extends EventEvaluatorBase<ILoggingEvent> {
  @Override
  public boolean evaluate(ILoggingEvent event) {
    // 这里写你的过滤逻辑，相当于原来 Janino 的 expression
    // 示例：只记录 com.example 包下 INFO 及以上级别，且消息包含 "order"
    return event.getLoggerName().startsWith("com.example")
        && event.getLevel().isGreaterOrEqual(Level.INFO)
        && event.getMessage() != null
        && event.getMessage().contains("order");
  }
}
